import React, { Component } from "react";
// 如果需要做高亮，要引入NavLink
// NavLink它具有Link的所有的功能，在Link的基础上增加了一个高亮效果
import { Route, Switch, NavLink } from "react-router-dom";
import "./08-style.css";

class Home extends Component {
  render() {
    return <div>这是home组件</div>;
  }
}

class About extends Component {
  render() {
    return <div>这是About组件</div>;
  }
}

const Mine = () => {
  return <div>这是我的组件</div>;
};

class App extends Component {
  state = {};
  render() {
    return (
      <>
        <h2>react-router-navLink</h2>
        <ul>
          <li>
            {/* activeClassName用来改变默认的class的类名 */}
            {/* 默认是active */}
            <NavLink to="/home" activeClassName="select">
              首页
            </NavLink>
          </li>
          <li>
            <NavLink to="/about" activeClassName="select">
              关于
            </NavLink>
          </li>
          <li>
            <NavLink to="/mine" activeClassName="select">
              我的
            </NavLink>
          </li>
        </ul>

        <hr />

        <Switch>
          <Route path="/home" component={Home}></Route>
          <Route path="/about" component={About}></Route>
          <Route path="/mine" component={Mine}></Route>
        </Switch>
      </>
    );
  }
}

export default App;
